import QtQuick 2.0;
import QtLocation 5.3
import "../../javascript/Utils.js" as UtilsJS

MapQuickItem {
    id: marker
    property string idFornecedor
    property string label
    property var image: null

    property alias lastMouseX: markerMouseArea.lastX
    property alias lastMouseY: markerMouseArea.lastY

    signal clicked(string idFornecedor, string label)

    anchorPoint.x: image.width/4
    anchorPoint.y: image.height

    sourceItem: Image {
        id: image
        source: marker.image?marker.image:"qrc:/images/marker.png"
        MouseArea  {
            id: markerMouseArea
            property int pressX : -1
            property int pressY : -1
            property int jitterThreshold : 10
            property int lastX: -1
            property int lastY: -1
            anchors.fill: parent
            hoverEnabled : false
            drag.target: marker
            preventStealing: true

            onPressed : {
                map.pressX = mouse.x
                map.pressY = mouse.y
                marker.clicked(idFornecedor,marker.label);
            }
        }

        Text{
            id: number
            text: marker.label
            y: -height
            color: "black"
            font.bold: true
            font.pixelSize: 14
            width:27
            horizontalAlignment: Text.AlignHCenter
        }

    }
}

